//=============================================================================
// Dual Laser Tripmine
//=============================================================================
class ClawFiremineAltProj extends ClawFiremineProj;


simulated function Destroyed()
{
    Super.Destroyed();
	if ( Laser2 != None )
		Laser2.Destroy();
}

//   Cut and paste form parent to work around issue with replication

simulated function Tick(float DeltaTime)
{
	if ( Role == ROLE_Authority )
		return;

	if ( !bOnWall && WallLocation != vect(0,0,0) ) {
		SetPhysics(PHYS_None);
		SetLocation(WallLocation);
		bOnWall = True;
	}
	if ( OppositeWallLocation != vect(0,0,0) && OppositeWallLocation2 != vect(0,0,0) && WallLocation != vect(0,0,0) )
    {
        SpawnEffect(OppositeWallLocation2, WallLocation - vector(Rotation) * 5);  // fix for the single laser beem issue?
		SpawnEffect(OppositeWallLocation, WallLocation - vector(Rotation) * 5);
		Disable('Tick');
	}
}

// end cut paste

state OnGround
{
	function Tick(float DeltaTime)
	{
		local vector HitLocation1, HitLocation2;
		local vector X, Y, Z;
		local Actor HitActor1, HitActor2;

		if ( !bDeleteMe && bArmed )
        {
			GetAxes(Rotation, X, Y, Z);
			HitLocation1 = TraceLaserHitLocation(Location - X * 5, Y, HitActor1, False);
			HitLocation2 = TraceLaserHitLocation(Location - X * 5, -Y, HitActor2, True);

			if ( OppositeWallLocation != HitLocation1 )
				Destroy();
			else if ( OppositeWallLocation2 != HitLocation2 )
				Destroy();
			else if (Level.Game.IsA('ChaosDuel') && Level.Game.IsInState('WaitingForNextRound'))
                Destroy();
		}
	}
}

simulated function BlowUp(Vector HitLocation)
{
	local vector X, Y, Z;

	Spawn(class'RocketExplosion',,, HitLocation - 20 * vector(Rotation));
	PlaySound(sound'TFMedia.Lasermine.lasermine_impact',, 2.5 * TransientSoundVolume);

	GetAxes(Rotation, X, Y, Z);
	Spawn(class'ClawFiremineBlast',,, HitLocation + 10 * Y - 5 * X, rotator(Y));
	Spawn(class'ClawFiremineBlast',,, HitLocation - 10 * Y - 5 * X, rotator(-Y));
	HurtDirectional(Damage, DamageRadius, DamageRadius * DamageDirectionAspect,
			MyDamageType, MomentumTransfer,
			HitLocation - 10 * vector(Rotation), OppositeWallLocation - HitLocation, True);
}

function ActivateMine()
{
	local Actor OppositeWall;
	local vector X, Y, Z;

	if ( Mover(ThisWall) != None ) {
		SetBase(ThisWall);
//		log("Attached to"@ThisWall, Name);
	}
	else if ( ThisWall != Level && StaticMeshActor(ThisWall) == None && TerrainInfo(ThisWall) == None
			 && (BlockingVolume(ThisWall) == None || !ThisWall.bProjTarget) ) {
		Destroy();
//		log(Level.TimeSeconds@"Not attached to wall:"@ThisWall, Name);
		return;
	}

	GetAxes(Rotation, X, Y, Z);

	OppositeWallLocation = TraceLaserHitLocation(Location - X * 5, Y, OppositeWall,,true);
	if ( OppositeWall == None )
		OppositeWallLocation = Location + 20000 * Y - X * 5;

	OppositeWallLocation2 = TraceLaserHitLocation(Location - X * 5, -Y, OppositeWall,,true);
	if ( OppositeWall == None )
		OppositeWallLocation2 = Location - 20000 * Y - X * 5;

//	log("ActivateMine:"@OppositeWallLocation@OppositeWallLocation2);

	SpawnEffect(OppositeWallLocation - Normal(OppositeWallLocation - Location) * 5 - X * 7, Location - X * 7);
	SpawnEffect(OppositeWallLocation2 - Normal(OppositeWallLocation2 - Location) * 5 - X * 7, Location - X * 7);
	bArmed = True;
	PlaySound(Sound'TFMedia.Lasermine.lasermine_activate');
//	log("Armed.", Name);
}

simulated function SpawnEffect(vector HitLocation, vector SmokeLocation)
{
	Laser2 = Laser;
//	log("hit local is " @HitLocation);
	Super.SpawnEffect(HitLocation, SmokeLocation);
}

defaultproperties
{
}
